import 'package:boss/color_constant.dart';
import 'package:boss/models/staff_tip_page_data.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/widget/custom_divier.dart';
import 'package:boss/ui/widget/shadow_radius_card.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class StaffTipItem extends StatelessWidget {
  final StaffTip data;
  final int index;

  const StaffTipItem({
    Key key,
    this.data,
    this.index,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var prices = AmountUtil.price2String(data.totalTip).split('.');
    var yuan = prices[0];
    var fen = prices[1];

    return Container(
      margin: EdgeInsets.only(
        top: 32.w,
      ),
      child: Stack(
        overflow: Overflow.visible,
        alignment: Alignment.topCenter,
        children: <Widget>[
          ShadowRadiusCard(
            padding: EdgeInsets.only(
              left: 25.w,
              right: 25.w,
              bottom: 23.w,
            ),
            child: Column(
              children: <Widget>[
                Container(
                  height: 140.w,
                  padding: EdgeInsets.only(
                    top: 26.w,
                  ),
                  child: Row(
                    children: <Widget>[
                      Expanded(
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                          children: <Widget>[
                            Text(
                              '${data.waiterName}',
                              style: TextStyleConstant().normal_1_32,
                            ),
                            Text(
                              '员工姓名',
                              style: TextStyleConstant().normal_3_24,
                            ),
                          ],
                        ),
                      ),
                      SizedBox(
                        width: 150.w,
                      ),
                      Expanded(
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                          children: <Widget>[
                            RichText(
                              text: TextSpan(text: '¥', style: TextStyleConstant().normal_1_24, children: [
                                TextSpan(
                                  text: '$yuan',
                                  style: TextStyleConstant().normal_1_32,
                                ),
                                TextSpan(
                                  text: '.$fen',
                                  style: TextStyleConstant().normal_1_24,
                                ),
                              ]),
                            ),
                            Text(
                              '小费合计',
                              style: TextStyleConstant().normal_3_24,
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
                CustomDivider(),
                Column(
                  children: <Widget>[
                    Container(
                      margin: EdgeInsets.only(
                        top: 22.w,
                        bottom: 17.w,
                      ),
                      child: Text(
                        '最新评价',
                        style: TextStyleConstant().normal_2_24,
                      ),
                    ),
                    Text(
                      '${data.latestComment}',
                      style: TextStyle(
                        fontSize: 24.sp,
                        color: ColorConstant.ff66,
                        height: 1.5,
                      ),
                      maxLines: 2,
                      overflow: TextOverflow.ellipsis,
                    )
                  ],
                ),
              ],
            ),
          ),
          if (index < 3)
            Positioned(
              top: -10.w,
              child: Container(
                width: 110.w,
                height: 36.w,
                decoration: BoxDecoration(
                    image: DecorationImage(
                  image: AssetImage('assets/image/staff_tip_badge.png'),
                )),
                alignment: Alignment.center,
                child: Text(
                  'NO.${index + 1}',
                  style: TextStyleConstant().white_22,
                ),
              ),
            ),
        ],
      ),
    );
  }
}
